package com.sxt.bus.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.bus.domain.Goods;
import com.sxt.bus.mapper.GoodsMapper;
import com.sxt.bus.service.GoodsService;
import com.sxt.bus.vo.GoodsVo;
import com.sxt.bus.utils.DataGridView;
@Service
public class GoodsServiceImpl implements GoodsService{

	@Autowired
	private GoodsMapper goodsMapper;
	
	
	@Override
	public DataGridView queryAllGoods(GoodsVo goodsVo) {
		Page<Object> page = PageHelper.startPage(goodsVo.getPage(),goodsVo.getLimit());
		List<Goods> data = goodsMapper.queryAllGoods(goodsVo);
		return new DataGridView(page.getTotal(),data);
	}

	@Override
	public Integer updateGoods(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.updateByPrimaryKeySelective(goodsVo);
	}

	@Override
	public Integer addGoods(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.insertSelective(goodsVo);
	}

	@Override
	public Integer deleteGoods(Integer id) {
		// TODO Auto-generated method stub
		
		
		
		return goodsMapper.deleteByPrimaryKey(id);
	}

	@Override
	public List<Goods> loadAllgoods(GoodsVo goodsVo) {
		// TODO Auto-generated method stub
		return goodsMapper.queryAllGoods(goodsVo);
	}

	@Override
	public List<Goods> loadGoodsByProviderId(Integer providerId) {
		// TODO Auto-generated method stub
		return goodsMapper.queryGoodsByProdiverId(providerId);
	}

}
